package io.renren.modules.logisticstracking.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.logisticstracking.entity.LogisticsTrackingEntity;
import io.renren.modules.logisticstracking.service.LogisticsTrackingService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 物流节点信息
 *
 * @author cyx
 * @email 714529684@qq.com
 * @date 2022-02-25 15:39:46
 */
@RestController
@RequestMapping("generator/logisticstracking")
public class LogisticsTrackingController {
    @Autowired
    private LogisticsTrackingService logisticsTrackingService;

    /**
     * 获取订单物流节点
     */
    @RequestMapping("/getAll/{waybillno}")
    @RequiresPermissions("generator:logisticstracking:getAll")
    public R getAll(@PathVariable("waybillno") Long waybillno){
        List<LogisticsTrackingEntity> list = logisticsTrackingService.getAll(waybillno);

        return R.ok().put("list", list);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:logisticstracking:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = logisticsTrackingService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("generator:logisticstracking:info")
    public R info(@PathVariable("id") Long id){
		LogisticsTrackingEntity logisticsTracking = logisticsTrackingService.getById(id);

        return R.ok().put("logisticsTracking", logisticsTracking);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:logisticstracking:save")
    public R save(@RequestBody LogisticsTrackingEntity logisticsTracking){
		logisticsTrackingService.save(logisticsTracking);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:logisticstracking:update")
    public R update(@RequestBody LogisticsTrackingEntity logisticsTracking){
		logisticsTrackingService.updateById(logisticsTracking);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:logisticstracking:delete")
    public R delete(@RequestBody Long[] ids){
		logisticsTrackingService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
